#!/usr/bin/env node

let argv = require('yargs')
  .usage('remarkpt')
  .example('remarkpt test.md test.html -o build -css ./static/otherCss.css')
  .options('o', {
    alias: 'output',  // 别名
    demand: false, //
    default: 'dist',
    describe: '输出目录'
  })
  .options('css', {
    demand: false,
    default: undefined,
    describe: '自定义样式表， 会复制到 输出目录/static/'
  })
  .options('p', {
    alias: 'port',
    demand: false,
    default: 2233,
    describe: '端口号'
  })
  .options('open', {
    type: 'boolean',
    demand: false,
    default: false,
    describe: 'PPT生成完成后是否开启本地服务'
  })
  .help('h')
  .alias('h', 'help')
  .argv;

function openServer() {
  let server = require('./server');
  server(argv.port, argv);
}

if (argv._[0] !== 'server') {
  let remarkPt = require('./src')();
  remarkPt(argv._[0], argv._[1], argv);
  if (argv.open) {
    argv.staticPath = argv.output || 'dist';
    argv.page = argv._[1] || 'index.html';
    openServer();
  }
} else {
  openServer();
}


